home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Text / SimpleText Sample / MacIncludes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-17  |  7.5 KB  |  241 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        MacIncludes.h
  3.  
  4.     Contains:    This file contains all of the Mac includes that one needs
  5.  
  6.     Version:    SimpleText 1.4 or later
  7.  
  8. ** Copyright 1993-1996 Apple Computer. All rights reserved.
  9. **
  10. **    You may incorporate this sample code into your applications without
  11. **    restriction, though the sample code has been provided "AS IS" and the
  12. **    responsibility for its operation is 100% yours.  However, what you are
  13. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  14. **    after having made changes. If you're going to re-distribute the source,
  15. **    we require that you make it clear in the source that the code was
  16. **    descended from Apple Sample Code, but that you've made changes.
  17.  
  18. */
  19.  
  20.  
  21. #ifndef __MACINCLUDES__
  22. #define __MACINCLUDES__
  23.  
  24. #ifndef BUILDING_FOR_SYSTEM7
  25. #define BUILDING_FOR_SYSTEM7 1
  26. #endif
  27.  
  28. #ifndef FOR_OPAQUE_SYSTEM_DATA_STRUCTURES
  29. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 0
  30. #endif
  31.  
  32. #ifndef PRAGMA_IMPORT_SUPPORTED
  33. #define PRAGMA_IMPORT_SUPPORTED 0
  34. #endif
  35.  
  36. #include <StdArg.h>
  37. #include <Limits.h>
  38. #include <Types.h>
  39. #include <Resources.h>
  40. #include <QuickDraw.h>
  41. #include <Fonts.h>
  42. #include <Events.h>
  43. #include <Windows.h>
  44. #include <Menus.h>
  45. #include <TextEdit.h>
  46. #include <Dialogs.h>
  47. #include <ToolUtils.h>
  48. #include <Memory.h>
  49. #include <SegLoad.h>
  50. #include <Files.h>
  51. #include <OSUtils.h>
  52. #include <Traps.h>    
  53. #include <Script.h>
  54. #include <ColorPicker.h>
  55. #include <FixMath.h>
  56. #include <Packages.h>
  57. #include <Math.h>
  58. #include <Palettes.h>
  59. #include <QDOffscreen.h>
  60. #include <DeskBus.h>
  61. #include <StdLib.h>
  62. #include <StdArg.h>
  63. #include <Strings.h>
  64. #include <StdIO.h>
  65. #include <Sound.h>
  66. #include <Errors.h>
  67. #include <AppleEvents.h>
  68. #include <DiskInit.h>
  69. #include <Retrace.h>
  70. #include <Folders.h>
  71. #include <Lists.h>
  72. #include <CTBUtilities.h>
  73. #include <Gestalt.h>
  74. #include <Finder.h>
  75. #include <Scrap.h>
  76. #include <Devices.h>
  77. #include <Video.h>
  78. #include <Aliases.h>
  79. #include <SoundInput.h>
  80. #include <Movies.h>
  81. #include <Printing.h>
  82. #include <Balloons.h>
  83. #include <MixedMode.h>
  84. #include <Drag.h>
  85. #include <TSMTE.h>
  86. #include <AppleGuide.h>
  87. #include <Speech.h>
  88. #include <Icons.h>
  89. #include <LowMem.h>
  90. #include <GXMath.h>
  91. #include <GXGraphics.h>
  92. #include <GXEnvironment.h>
  93. #include <GXFonts.h>
  94. #include <GXLayout.h>
  95. #include <GXPrinting.h>
  96. #include <GXMessages.h>
  97. #include <CodeFragments.h>
  98. #include <TextUtils.h>
  99.  
  100. // ----- BEGINNING OF SWIPED MACROS -----
  101. // Things that should be in the standard Maxwell versions of headers, but
  102. // are not.  Probably should clean up a bit w.r.t. using window refs and the like
  103.  
  104. #define    GetWindowPort(aWindowRef)                        ( (CGrafPtr) aWindowRef)
  105. #define    GetWindowKind(aWindowRef)                        ( *(SInt16 *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort)))
  106. #define GetWindowUpdateRgn(aWindowRef, aRgnHandle)        CopyRgn( *(RgnHandle *)(((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0xE), \
  107.                                                                 aRgnHandle )
  108. #define GetNextWindow(aWindowRef)                        ( *(WindowRef *)    (((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x24))
  109. #define GetWindowStructureRgn(aWindowRef, aRgnHandle)    CopyRgn( *(RgnHandle *)(((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0x6), \
  110.                                                                 aRgnHandle )
  111. #define GetWindowContentRgn(aWindowRef, aRgnHandle)        CopyRgn( *(RgnHandle *)(((UInt8 *) aWindowRef) + sizeof(GrafPort) + 0xA), \
  112.                                                                 aRgnHandle )
  113.  
  114. #define GetDialogWindow(dialog)    ((WindowRef) dialog)
  115. #define GetDialogKeyboardFocusItem(dialog) ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1)
  116.  
  117. // ----- END OF SWIPED MACROS -----
  118.  
  119. #include "AGFile.h"
  120.  
  121. // Balloons.h
  122. #define kDefaultBalloonVariant    2
  123.  
  124. // Fonts.h
  125. #if !GENERATINGPOWERPC
  126.     pascal short GetDefFontSize(void)
  127.     = {0x3EB8,0x0BA8,0x6604,0x3EBC,0x000C};
  128. #endif
  129.  
  130. // GXPrinterDrivers.h
  131. #if GENERATINGPOWERPC
  132.     // in the old library, these are not automagically remapped from the
  133.     // forward messages, so we do so via Macros.  At some point, can remove
  134.     // this once SCM libs catch up.
  135.     #undef Forward_GXPrintingEvent
  136.     #undef Forward_GXCompleteSpoolFile
  137.     #undef Send_GXSpoolResource
  138.     
  139. // Jason Yeo: the follwoing 3 functions used to be extern Psacal OSErr ....
  140.     extern OSErr Forward_GXPrintingEvent(EventRecord *evtRecord, Boolean filterEvent);
  141.     extern OSErr Forward_GXCompleteSpoolFile(gxSpoolFile theSpoolFile);    
  142.     extern OSErr Send_GXSpoolResource(gxSpoolFile theSpoolFile, Handle theResource, ResType theType, long id);    
  143. #endif
  144.  
  145. // For looking at all of our windows, not just the visible ones.
  146. #define    LMGetFirstWindow() (* (WindowRef*) 0x9D6)
  147.  
  148. // No glue for this either, sigh.
  149. #define TESetClickLoop(L,H) ((**(H)).clickLoop = (L))
  150.  
  151. // defines I like to use all of the time
  152. extern void _DataInit();        // part of Runtime library
  153.  
  154. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  155. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  156.  
  157. #define RectWidth(aRect) ((aRect).right - (aRect).left)
  158. #define RectHeight(aRect) ((aRect).bottom - (aRect).top)
  159.  
  160. #define Max(X, Y) ( ((X)>(Y)) ? (X) : (Y) )
  161. #define Min(X, Y) (  ((X)>(Y)) ? (Y) : (X) )
  162.  
  163. #define Pin(VALUE, MIN, MAX) ( ((VALUE) < (MIN)) ? (MIN) : ( ((VALUE) > (MAX)) ? (MAX) : (VALUE) ) )
  164.  
  165. #define nrequire(CONDITION, LABEL) if (true) {if ((CONDITION)) goto LABEL; }
  166. #define require(CONDITION, LABEL) if (true) {if (!(CONDITION)) goto LABEL; }
  167.  
  168. // The Pascal equivalent of strcpy, takes two Pascal string pointers
  169. #define PSTRCPY(P1, P2)    BlockMove(P2, P1, P2[0]+1)
  170.  
  171. // Concatante one character C onto the string S 
  172. #define CHARCAT(S, C)    S[(S[0]+1)] = C; S[0]++;
  173.  
  174. /* The Pascal equivalent of strcat, takes two Pascal string pointers */
  175. #define PSTRCAT(P1, P2)                         \
  176.     BlockMove(&P2[1], &P1[(P1[0]+1)], P2[0]);    \
  177.     P1[0] += P2[0];
  178.  
  179. #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION < 0x300)
  180. #define CheckMenuItem(menu, item, checked) CheckItem(menu, item, checked)
  181. #endif
  182.  
  183. #endif /* __MACINCLUDES__ */
  184.  
  185. /* 
  186.  * The following drag enums and typedefs are from the beta 3.0 version of Interfaces and Libraries upon 
  187.  * which SimpleText was orginally built. Since the 3.0 version was removed, they
  188.  * are necessary for compatibilty with the 2.x interfaces and libraries.
  189.  *
  190.  * Should these be put back in future versions of Interface files, you can just remove these declarations.
  191.  *
  192.  */
  193.  
  194. enum {
  195.     kDragTrackingEnterHandler    = 1,                            /* drag has entered handler*/
  196.     kDragTrackingEnterWindow    = 2,                            /* drag has entered window*/
  197.     kDragTrackingInWindow        = 3,                            /* drag is moving within window*/
  198.     kDragTrackingLeaveWindow    = 4,                            /* drag has exited window*/
  199.     kDragTrackingLeaveHandler    = 5                                /* drag has exited handler*/
  200. };
  201.  
  202. enum {
  203.     kNullCharCode                = 0,
  204.     kHomeCharCode                = 1,
  205.     kEnterCharCode                = 3,
  206.     kEndCharCode                = 4,
  207.     kHelpCharCode                = 5,
  208.     kBellCharCode                = 7,
  209.     kBackspaceCharCode            = 8,
  210.     kTabCharCode                = 9,
  211.     kLineFeedCharCode            = 10,
  212.     kVerticalTabCharCode        = 11,
  213.     kPageUpCharCode                = 11,
  214.     kFormFeedCharCode            = 12,
  215.     kPageDownCharCode            = 12,
  216.     kReturnCharCode                = 13,
  217.     kFunctionKeyCharCode        = 16,
  218.     kEscapeCharCode                = 27,
  219.     kClearCharCode                = 27,
  220.     kLeftArrowCharCode            = 28,
  221.     kRightArrowCharCode            = 29,
  222.     kUpArrowCharCode            = 30,
  223.     kDownArrowCharCode            = 31,
  224.     kDeleteCharCode                = 127,
  225.     kNonBreakingSpaceCharCode    = 202
  226. };
  227.  
  228. /*
  229. _______________________________________________________________________________________________________
  230.     
  231.  • DRAG ATTRIBUTES
  232. _________________________________________________________________________________________________________
  233. */
  234. typedef OptionBits DragAttributes;
  235.  
  236. enum {
  237.     kDragHasLeftSenderWindow    = (1L << 0),                    /* drag has left the source window since TrackDrag*/
  238.     kDragInsideSenderApplication = (1L << 1),                    /* drag is occurring within the sender application*/
  239.     kDragInsideSenderWindow        = (1L << 2)                        /* drag is occurring within the sender window*/
  240. };
  241.